package com.niit.session17.set;


//如果要对一个引用数据类型排序就需要这个类实现Comparable接口
public class Student implements Comparable<Student>{
	private String name;
	private int age;
	
	
	//compareTo用于写这个类的排序规则
	@Override
	public int compareTo(Student o) {
		if(o.getAge()>=age) {
			return -1;
		}else if(o.getAge()<age){
			return 1;
		}else {
			return 0;
		}
	}


	public Student(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}

	public Student() {
		super();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "Student [name=" + name + ", age=" + age + "]";
	}

}
